/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package kimo.bl;

import labels.LabelsEnum;
import java.util.Date;
import org.zkoss.util.resource.Labels;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zul.Checkbox;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Textbox;

/**
 *
 * @author a381u296
 */
public class zkUtils {

    public static void myMessagebox(LabelsEnum caption) {
        //Messagebox.show(rb.getString(LabelsEnum.AFM_NOT_COMPLETED_APPLICATION.toString()));

        Messagebox.show(Labels.getLabel(caption.toString()));

    }

    /**
     * Assigns String to a textbox only if it is not null or empty
     *
     * @param textbox Textbox
     * @param string String
     */
    public static void setTextboxValue(Textbox textbox, String string) {
        if (string != null) {
            if (!"".equals(string)) {
                textbox.setValue(string);
            }
        }
    }

    /**
     * Assigns date to a Datebox only if its not null
     *
     * @param datebox
     * @param date
     */
    public static void setDateboxValue(Datebox datebox, Date date) {
        if (date != null) {
            datebox.setValue(date);
        }
    }

    
    public static void setCheckValue(Checkbox checkbox, Boolean value) {
        if (value != null) {
            checkbox.setChecked(value);
        }
    }
    
     public static void throwWrongValueException(Listbox listbox, String Message ) {
       throw new WrongValueException(listbox, Message);
    }
    
    public static void throwWrongValueException(Textbox textbox, String Message ) {
       throw new WrongValueException(textbox, Message);
    }
    
    
}
